import java.util.Scanner;

public class Main1584 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        int max=0;
        int min=arr[0];
        for (int i=0;i< arr.length;i++){
            if (max<arr[i]){
                max=arr[i];
            }if (min>arr[i]){
                min=arr[i];
            }
        }
        int a=0;//一次
        int b=0;
        for (int i=0;i< arr.length;i++){
            if (arr[i]==max){
                a=arr[i];

            }
            if (arr[i]==min){
                b=b+arr[i];
            }
        }
        int s1=a+b;
        int s2=0;
        for (int i=0;i<n;i++){
            s2=s2+arr[i];
        }
        System.out.println(s1);
        System.out.println(s2-s1);
    }
}
